from .scope import Scope
from .container import Container


class WhileBlock(Container):
    
    def __init__(self, condition):
        
        Container.__init__(self)
        self.__condition = condition
        
    def render(self, scope):
        
        while_scope = Scope(scope)
        lines = []
        while self.__condition.is_true(while_scope):
            for block in self._body:
                lines += block.render(while_scope)
            
        return lines